package com.squareup.square.legacy.models;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.apimatic.core.types.OptionalNullable;
import java.util.Objects;

/**
 * This is a model class for CatalogImage type.
 */
public class CatalogImage {
    private final OptionalNullable<String> name;
    private final OptionalNullable<String> url;
    private final OptionalNullable<String> caption;
    private final OptionalNullable<String> photoStudioOrderId;

    /**
     * Initialization constructor.
     * @param  name  String value for name.
     * @param  url  String value for url.
     * @param  caption  String value for caption.
     * @param  photoStudioOrderId  String value for photoStudioOrderId.
     */
    @JsonCreator
    public CatalogImage(
            @JsonProperty("name") String name,
            @JsonProperty("url") String url,
            @JsonProperty("caption") String caption,
            @JsonProperty("photo_studio_order_id") String photoStudioOrderId) {
        this.name = OptionalNullable.of(name);
        this.url = OptionalNullable.of(url);
        this.caption = OptionalNullable.of(caption);
        this.photoStudioOrderId = OptionalNullable.of(photoStudioOrderId);
    }

    /**
     * Initialization constructor.
     * @param  name  String value for name.
     * @param  url  String value for url.
     * @param  caption  String value for caption.
     * @param  photoStudioOrderId  String value for photoStudioOrderId.
     */
    protected CatalogImage(
            OptionalNullable<String> name,
            OptionalNullable<String> url,
            OptionalNullable<String> caption,
            OptionalNullable<String> photoStudioOrderId) {
        this.name = name;
        this.url = url;
        this.caption = caption;
        this.photoStudioOrderId = photoStudioOrderId;
    }

    /**
     * Internal Getter for Name.
     * The internal name to identify this image in calls to the Square API. This is a searchable
     * attribute for use in applicable query filters using the
     * [SearchCatalogObjects](api-endpoint:Catalog-SearchCatalogObjects). It is not unique and
     * should not be shown in a buyer facing context.
     * @return Returns the Internal String
     */
    @JsonGetter("name")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonSerialize(using = OptionalNullable.Serializer.class)
    protected OptionalNullable<String> internalGetName() {
        return this.name;
    }

    /**
     * Getter for Name.
     * The internal name to identify this image in calls to the Square API. This is a searchable
     * attribute for use in applicable query filters using the
     * [SearchCatalogObjects](api-endpoint:Catalog-SearchCatalogObjects). It is not unique and
     * should not be shown in a buyer facing context.
     * @return Returns the String
     */
    @JsonIgnore
    public String getName() {
        return OptionalNullable.getFrom(name);
    }

    /**
     * Internal Getter for Url.
     * The URL of this image, generated by Square after an image is uploaded using the
     * [CreateCatalogImage](api-endpoint:Catalog-CreateCatalogImage) endpoint. To modify the image,
     * use the UpdateCatalogImage endpoint. Do not change the URL field.
     * @return Returns the Internal String
     */
    @JsonGetter("url")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonSerialize(using = OptionalNullable.Serializer.class)
    protected OptionalNullable<String> internalGetUrl() {
        return this.url;
    }

    /**
     * Getter for Url.
     * The URL of this image, generated by Square after an image is uploaded using the
     * [CreateCatalogImage](api-endpoint:Catalog-CreateCatalogImage) endpoint. To modify the image,
     * use the UpdateCatalogImage endpoint. Do not change the URL field.
     * @return Returns the String
     */
    @JsonIgnore
    public String getUrl() {
        return OptionalNullable.getFrom(url);
    }

    /**
     * Internal Getter for Caption.
     * A caption that describes what is shown in the image. Displayed in the Square Online Store.
     * This is a searchable attribute for use in applicable query filters using the
     * [SearchCatalogObjects](api-endpoint:Catalog-SearchCatalogObjects).
     * @return Returns the Internal String
     */
    @JsonGetter("caption")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonSerialize(using = OptionalNullable.Serializer.class)
    protected OptionalNullable<String> internalGetCaption() {
        return this.caption;
    }

    /**
     * Getter for Caption.
     * A caption that describes what is shown in the image. Displayed in the Square Online Store.
     * This is a searchable attribute for use in applicable query filters using the
     * [SearchCatalogObjects](api-endpoint:Catalog-SearchCatalogObjects).
     * @return Returns the String
     */
    @JsonIgnore
    public String getCaption() {
        return OptionalNullable.getFrom(caption);
    }

    /**
     * Internal Getter for PhotoStudioOrderId.
     * The immutable order ID for this image object created by the Photo Studio service in Square
     * Online Store.
     * @return Returns the Internal String
     */
    @JsonGetter("photo_studio_order_id")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonSerialize(using = OptionalNullable.Serializer.class)
    protected OptionalNullable<String> internalGetPhotoStudioOrderId() {
        return this.photoStudioOrderId;
    }

    /**
     * Getter for PhotoStudioOrderId.
     * The immutable order ID for this image object created by the Photo Studio service in Square
     * Online Store.
     * @return Returns the String
     */
    @JsonIgnore
    public String getPhotoStudioOrderId() {
        return OptionalNullable.getFrom(photoStudioOrderId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, url, caption, photoStudioOrderId);
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == this) {
            return true;
        }
        if (!(obj instanceof CatalogImage)) {
            return false;
        }
        CatalogImage other = (CatalogImage) obj;
        return Objects.equals(name, other.name)
                && Objects.equals(url, other.url)
                && Objects.equals(caption, other.caption)
                && Objects.equals(photoStudioOrderId, other.photoStudioOrderId);
    }

    /**
     * Converts this CatalogImage into string format.
     * @return String representation of this class
     */
    @Override
    public String toString() {
        return "CatalogImage [" + "name=" + name + ", url=" + url + ", caption=" + caption + ", photoStudioOrderId="
                + photoStudioOrderId + "]";
    }

    /**
     * Builds a new {@link CatalogImage.Builder} object.
     * Creates the instance with the state of the current model.
     * @return a new {@link CatalogImage.Builder} object
     */
    public Builder toBuilder() {
        Builder builder = new Builder();
        builder.name = internalGetName();
        builder.url = internalGetUrl();
        builder.caption = internalGetCaption();
        builder.photoStudioOrderId = internalGetPhotoStudioOrderId();
        return builder;
    }

    /**
     * Class to build instances of {@link CatalogImage}.
     */
    public static class Builder {
        private OptionalNullable<String> name;
        private OptionalNullable<String> url;
        private OptionalNullable<String> caption;
        private OptionalNullable<String> photoStudioOrderId;

        /**
         * Setter for name.
         * @param  name  String value for name.
         * @return Builder
         */
        public Builder name(String name) {
            this.name = OptionalNullable.of(name);
            return this;
        }

        /**
         * UnSetter for name.
         * @return Builder
         */
        public Builder unsetName() {
            name = null;
            return this;
        }

        /**
         * Setter for url.
         * @param  url  String value for url.
         * @return Builder
         */
        public Builder url(String url) {
            this.url = OptionalNullable.of(url);
            return this;
        }

        /**
         * UnSetter for url.
         * @return Builder
         */
        public Builder unsetUrl() {
            url = null;
            return this;
        }

        /**
         * Setter for caption.
         * @param  caption  String value for caption.
         * @return Builder
         */
        public Builder caption(String caption) {
            this.caption = OptionalNullable.of(caption);
            return this;
        }

        /**
         * UnSetter for caption.
         * @return Builder
         */
        public Builder unsetCaption() {
            caption = null;
            return this;
        }

        /**
         * Setter for photoStudioOrderId.
         * @param  photoStudioOrderId  String value for photoStudioOrderId.
         * @return Builder
         */
        public Builder photoStudioOrderId(String photoStudioOrderId) {
            this.photoStudioOrderId = OptionalNullable.of(photoStudioOrderId);
            return this;
        }

        /**
         * UnSetter for photoStudioOrderId.
         * @return Builder
         */
        public Builder unsetPhotoStudioOrderId() {
            photoStudioOrderId = null;
            return this;
        }

        /**
         * Builds a new {@link CatalogImage} object using the set fields.
         * @return {@link CatalogImage}
         */
        public CatalogImage build() {
            return new CatalogImage(name, url, caption, photoStudioOrderId);
        }
    }
}
